package kaug.loeng2;

/**
 * How to use command-line arguments.
 * @author Ago
 *
 */
public class Main {

	/**
	 * main.
	 * @param args Arguments as String array.
	 */
	public static void main(String[] args) {
		// massiiv: 0, 1, 2, 3...length
		// {1, 2, 3, 4}
		// {"Tere", "tulemast"}
		
		String[] args2 = {"-u"};
		// String[] args2 = new String[2];
		// args2[0] = "-u";
		// args2[1] = "tere";
		//args = args2;
		
		if (args.length == 0) {
			help();
		}
		
		
		boolean uppercase = false;
		String name = "";
		// myprogram 1 tere 2
		for (int i = 0; i < args.length; i++) {
			if (args[i].equals("-u")) {
				uppercase = true;
			} else {
				name += args[i] + " ";
			}
			//System.out.println(args[i]);
		}
		if (name.equals("")) {
			help();
		}
		
		if (uppercase) {
			System.out.println(name.toUpperCase());
		} else {
			System.out.println(name);
		}
		
		

	}

	/**
	 * Prints out help text (how to use the program).
	 */
	public static void help() {
		System.out.println("Usage: program [-u] name1 [name2] ..");
		System.exit(0);
	}
}
